<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	<meta http-equiv="Pragma" content="no-cache" /> 
	<meta http-equiv="Cache-Control" content="no-cache" /> 
	<meta http-equiv="Expires" content="0" />
	
	<link href="images/reset.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
	<link href="images/system.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
	<link href="images/table_form.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
	<script src="{yun:}$config.sy_weburl{/yun}/js/jquery-1.8.0.min.js?v={yun:}$config.cachecode{/yun}"></script>
	<script src="js/admin_public.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
	<link href="{yun:}$config.sy_weburl{/yun}/js/layui/css/layui.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet">
	<script src="{yun:}$config.sy_weburl{/yun}/js/layui/layui.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
	<script src="{yun:}$config.sy_weburl{/yun}/js/layui/phpyun_layer.js?v={yun:}$config.cachecode{/yun}"></script>

	<title>后台管理</title>

</head>

<body class="body_ifm">
	<div class="infoboxp"> 
		<div class="admin_new_tip">
			<a href="javascript:;" class="admin_new_tip_close"></a>
			<a href="javascript:;" class="admin_new_tip_open" style="display:none;"></a>
			<div class="admin_new_tit"><i class="admin_new_tit_icon"></i>操作提示</div>
			
			<div class="admin_new_tip_list_cont">
				<div class="admin_new_tip_list">可以使用QQ/163等邮箱，465端口需要开启SSL服务，注意邮箱密码不是账户密码一般是独立授权密码</div>
			</div>
		</div>

		<div class="clear"></div>

		<div class="main_tag mt10">
			<div class="tag_box">

				<iframe id="supportiframe"  name="supportiframe" onload="returnmessage('supportiframe');" style="display:none"></iframe>
				<form  target="supportiframe" name="myform" action="index.php?m=emailconfig&c=save" method="post"  onSubmit="return checkform(this);" class="layui-form">

					<table width="100%" class="table_form">
						<tr class="admin_table_trbg">
							<th width="200" bgcolor="#f0f6fb"><span class="admin_bold">参数说明</span></th>
							<td bgcolor="#f0f6fb"><span class="admin_bold">参数值</span></td>
						</tr>
						<tr>
							<th width="200" style="width:160px;">邮件发送方式：</th>
							<td>
								<div class="layui-form-item">
									<div class="layui-input-block">
										<div class="layui-input-inline">
											<input type="radio" name="sy_email_online" value="1" lay-filter="type" id="sy_email_online_1" {yun:}if $config.sy_email_online=="1"{/yun}checked{yun:}/if{/yun} title="SMTP服务器发送邮件" >
											<input type="radio" name="sy_email_online" value="2" lay-filter="type" id="sy_email_online_2" {yun:}if $config.sy_email_online=="2"{/yun}checked{yun:}/if{/yun} title="阿里云DirectMail" >
										</div>
									</div>
								</div>
							</td>
						</tr>
					</table> 

					<div id="emailtable" {yun:}if $config.sy_email_online=="2"{/yun}style="display:none;"{yun:}/if{/yun}>
						{yun:}foreach from=$emailconfig item=eclist{/yun}
							<table width="100%" class="table_form">
								<tr class="email admin_table_trbg">
									<th width="200">SMTP服务器：</th>
									<td><input class="input-text tips_class" type="text" name="smtpserver_{yun:}$eclist.id{/yun}" value="{yun:}$eclist.smtpserver{/yun}" size="30" maxlength="255"/><span class="admin_web_tip">如：smtp.qq.com</span></td>
								</tr>
								<tr class="email">
									<th width="200">SMTP服务器的用户邮箱：</th>
									<td><input class="input-text tips_class" type="text" name="smtpuser_{yun:}$eclist.id{/yun}" value="{yun:}$eclist.smtpuser{/yun}" size="30" maxlength="255"/><span class="admin_web_tip">如：phpyun@qq.com</span></td>
								</tr>
								<tr class="email">
									<th width="200">邮箱密码：</th>
									<td><input class="input-text tips_class" type="password" name="smtppass_{yun:}$eclist.id{/yun}"  value="{yun:}$eclist.smtppass{/yun}" size="30" maxlength="255"/><span class="admin_web_tip">注：此处密码一般为邮箱独立的授权密码而并非原始邮箱密码，具体可查看各邮箱设置详细信息</span></td>
								</tr>
								<tr class="email admin_table_trbg">
									<th width="200">SMTP服务器端口: </th>
									<td><input class="input-text tips_class" type="text" name="smtpport_{yun:}$eclist.id{/yun}" value="{yun:}$eclist.smtpport{/yun}" size="30" maxlength="255"/><span class="admin_web_tip">注：普通邮箱端口为25 企业邮箱端口为465，如使用465端口 请确保服务器开启SSL服务</span></td>
								</tr>
								<tr>
									<th width="200">发件人昵称: </th>
									<td><input class="input-text tips_class" type="text" name="smtpnick_{yun:}$eclist.id{/yun}" value="{yun:}$eclist.smtpnick{/yun}" size="30" maxlength="255"/></td>
								</tr>
								
								<tr class="admin_table_trbg">
										<th width="200">启用邮箱：</th>
										<td>
										<div class="layui-form-item">
										  <div class="layui-input-block">
											 <div class="layui-input-inline">
											   <input id="default_{yun:}$eclist.id{/yun}_0" type="radio" {yun:}if $eclist.default!='1'{/yun}checked=""{yun:}/if{/yun} value="0" name="default_{yun:}$eclist.id{/yun}" title="关闭" >
											   <input id="default_{yun:}$eclist.id{/yun}_1" type="radio" {yun:}if $eclist.default=='1'{/yun}checked=""{yun:}/if{/yun} value="1" name="default_{yun:}$eclist.id{/yun}" title="开启" >
											 </div>
										   </div>
										</div>
										</td>
									</tr>
								<input type='hidden' name='emailid[]' value='{yun:}$eclist.id{/yun}'>
								<tr class="email admin_table_trbg">
									<th width="200">&nbsp;</th>
									<td align="left">
										<input class="admin_submit_bthy deleteconfig" data-id='{yun:}$eclist.id{/yun}' type="button" value="删除" >&nbsp;&nbsp;
										<input class="admin_submit_bthy testconfig"  data-id='{yun:}$eclist.id{/yun}' type="button"  value="测试">
									</td>
								</tr>
							</table>
						{yun:}foreachelse{/yun}
							<script>
								$(function(){  
									$('#emailtable').append($('#appendconfig').html());
								});   
							</script>
						{yun:}/foreach{/yun}
					</div>

					<table width="100%" class="table_form emailtable" {yun:}if $config.sy_email_online=="2"{/yun}style="display:none;"{yun:}/if{/yun}>
						<tr class="email admin_table_trbg">
						 <th width="200">&nbsp;</th>
							<td align="left">
								<input class="layui-btn layui-btn-normal"  type="submit" name="config" value="保存" />&nbsp;&nbsp;
								<input class="layui-btn layui-btn-normal" type="button" value="新增" onclick="javascript:$('#emailtable').append($('#appendconfig').html());" />
							</td>
						</tr>
					</table>




					<div id="aliyunemail" {yun:}if $config.sy_email_online=="1"{/yun}style="display:none;"{yun:}/if{/yun}>
						<table width="100%" class="table_form">
							<tr class="email admin_table_trbg">
								<th width="200">AccessKey ID：</th>
								<td><input class="input-text tips_class" type="text" name="accesskey" value="{yun:}$config.accesskey{/yun}" size="30" maxlength="255"/><span class="admin_web_tip">如：j8Blubzc8v4BwQte</span></td>
							</tr>
							<tr class="email">
								<th width="200">Access Key Secret：</th>
								<td><input class="input-text tips_class" type="text" name="accesssecret" value="{yun:}$config.accesssecret{/yun}" size="30" maxlength="255"/><span class="admin_web_tip">如：phpyun@qq.com</span></td>
							</tr>
							<tr class="email">
								<th width="200">发信地址：</th>
								<td><input class="input-text tips_class" type="text" name="ali_email"  value="{yun:}$config.ali_email{/yun}" size="30" maxlength="255"/></td>
							</tr>
							<tr class="email admin_table_trbg">
								<th width="200">标签: </th>
								<td><input class="input-text tips_class" type="text" name="ali_tag" value="{yun:}$config.ali_tag{/yun}" size="30" maxlength="255"/></td>
							</tr>
							<tr>
								<th width="200">发件人昵称: </th>
								<td><input class="input-text tips_class" type="text" name="ali_name" value="{yun:}$config.ali_name{/yun}" size="30" maxlength="255"/></td>
							</tr>
						</table>
					</div>

					<table width="100%" class="table_form aliyunemail" {yun:}if $config.sy_email_online=="1"{/yun}style="display:none;"{yun:}/if{/yun}>
						<tr class="email admin_table_trbg">
							<th width="200">&nbsp;</th>
							<td align="left">
								<input class="layui-btn layui-btn-normal"  type="submit" name="aliconfig" value="保存" />&nbsp;&nbsp;
								<input class="layui-btn layui-btn-normal testconfig" data-id="aliyun" type="button" value="测试" />
							</td>
						</tr>
					</table>
				<input type="hidden" name="pytoken" id='pytoken' value="{yun:}$pytoken{/yun}"> 
			</form>
		</div>
	</div>






<div style="display:none;" id="appendconfig">
	<table width="100%" class="table_form">
		<tr class="email admin_table_trbg">
			<th width="200">SMTP服务器：</th>
			<td><input class="input-text tips_class" type="text" name="smtpserver[]"  value="" size="30" maxlength="255"/><span class="admin_web_tip">如：smtp.qq.com</span></td>
		</tr>
		<tr class="email">
			<th width="200">SMTP服务器的用户邮箱：</th>
			<td><input class="input-text tips_class" type="text" name="smtpuser[]"  value="" size="30" maxlength="255"/><span class="admin_web_tip">如：phpyun@qq.com</span></td>
		</tr>
		<tr class="email">
			<th width="200">邮箱密码：</th>
			<td><input class="input-text tips_class" type="password" name="smtppass[]"  value="" size="30" maxlength="255"/><span class="admin_web_tip">注：此处密码一般为邮箱独立的授权密码而并非原始邮箱密码，具体可查看各邮箱设置详细信息</span></td>
		</tr>
		<tr class="email admin_table_trbg">
			<th width="200">SMTP服务器端口: </th>
			<td><input class="input-text tips_class" type="text" name="smtpport[]"  value="" size="30" maxlength="255"/><span class="admin_web_tip">注：普通邮箱端口为25 企业邮箱端口为465，如使用465端口 请确保服务器开启SSL服务</span></td>
		</tr>
		<tr>
			<th width="200">发件人昵称: </th>
			<td><input class="input-text tips_class" type="text" name="smtpnick[]"  value="" size="30" maxlength="255"/></td>
		</tr>
		
	</table>
</div>

<script> 
	layui.use(['layer', 'form'], function(){
		var layer = layui.layer
		,form = layui.form
		,$ = layui.$;
		form.on('radio(type)', function(data){
			if(data.value=='1'){
				$('#aliyunemail').hide();
				$('#emailtable').show();
				$('.aliyunemail').hide();
				$('.emailtable').show();
			}else{
				$('#aliyunemail').show();
				$('#emailtable').hide();
				$('.aliyunemail').show();
				$('.emailtable').hide();
			}
			form.render();
		}); 
	});
	$(function(){  
		$('.testconfig').click(function(){
			var id = $(this).attr('data-id');
			if(!id){
				layer.msg('请选择需要测试的邮件服务器！',2,8);
			}else{
				layer.prompt({height:'20px',title: '填写测试邮箱',top:'50px'}, function(value){ 
					if(value){
						var myreg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/;
						var pytoken=$("#pytoken").val();
						if(!myreg.test(value)){
							parent.layer.msg('邮箱格式不正确，请重新输入！', 2, 8);return false;
						}else{ 
							var ii = parent.layer.load('发送中…',0);
							$.post("index.php?m=emailconfig&c=ceshi",{ceshi_email:value,id:id,pytoken:pytoken},function(data){
								var data=eval('('+data+')');
								parent.layer.close(ii);
								parent.layer.msg(data.msg, 2, Number(data.type));return false; 
							}); 
						}
					}else{
						parent.layer.msg('请输入邮箱！',2,8);return false; 
					} 
				})
			}
		});
		$('.deleteconfig').click(function(){
			var id = $(this).attr('data-id');
			if(!id){
				layer.msg('请选择需要删除的邮件服务器！',2,8);
			}else{
				var pytoken=$("#pytoken").val();
				layer.confirm("确定删除吗？",function(){
					var ii = layer.load('执行中…',0);
					$.post('index.php?m=emailconfig&c=delconfig',{id:id,pytoken:pytoken},function(data){
						parent.layer.close(ii);
						var data=eval('('+data+')');
						layer.msg(data.msg, 2, Number(data.type),function(){location.reload();});
					})
				});
			}
		});
	});  
	
	function checkform(){

		var sy_email_online = $("input:radio[name='sy_email_online']:checked").val();
		if(sy_email_online==''){
			layer.msg('请选择邮件发送方式！',2,8);
		}
 		
	}
</script>
</div>
</body>
</html>